<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Java实训课程 - 收入</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script src="libs/handlebars.min.js"></script>
<script src="libs/js.cookie-2.1.0.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h2>
					用户收入金额
					<button id="querynull" class="btn btn-primary pull-right">退出</button>
				</h2>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="col-md-8">
			<ul class="nav nav-pills">
				<li><a href="index.html">首页</a></li>
				<li class="active"><a href="#">新加收入</a></li>
				<li><a href="zhichu.html">新加支出</a></li>
				<li><a href="query.html">查询</a></li>
				<li><a href="count.html">统计</a></li>
				<li><a href="#">用户：<span id="nickname"></span></a></li>
			</ul>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<hr />
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-4 col-md-offset-4">
				<div class="form-group">
					<label for="date_time">时间</label> <input type="date"
						class="form-control" id="date_time" />
				</div>
				<div class="form-group">
					<label for="place">地点</label> <input type="text"
						class="form-control" id="place" />
				</div>
				<div class="form-group">
					<label for="money_in">收入</label> <input type="text"
						class="form-control" id="money_in" />
				</div>
				<div class="form-group">
					<label for="kind">类别</label> <input type="text"
						class="form-control" id="kind" />
				</div>
				<div class="form-group">
					<label for="remark">备注</label> <input type="text"
						class="form-control" id="remark" />
				</div>
				<button id="shouru" class="btn btn-primary btn-block">添加</button>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	if (!Cookies.get("user")) {
		window.location.href = 'login.html';
	}
	$(function() {
		$.getJSON('queryUsers.action', function(res) {
			//console.log(res);  
			$('#nickname').text(res.nk)
		})

		$('#shouru').click(function() {
			$.post('shouru.action', {
				date_time : $('#date_time').val(),
				place : $('#place').val(),
				money_in : $('#money_in').val(),
				kind : $('#kind').val(),
				remark : $('#remark').val()
			}, function(res, status) {
				console.log(res);
				if ('OK' == res) {
					alert('添加成功');
				}
				window.location.href = "index.html";
			})
		})

		$('#querynull').click(function() {
			$.post('querynull.action', {}, function(res, status) {
				if ('OK' == res) {
					alert('确定退出本次登陆');
				}
				window.location.href = "login.html";
			});
		});
	})
</script>
</html>
